Generic Comment Recursively-nestable comments
[show modes: view edit reply]

[begin mode overview]
[msg_start();]
<span style="float: right; font-size: 80%;">
[
    if(can_edit()) { <a href="/?mode=edit&id=[$_id]">edit</a> };
    if(can_direct()) { <a href="/?mode=delete&id=[$_id]">delete</a> };
    if(can_comment()) { <a href="?id=[$_id]&mode=reply">reply</a> };
]
</span>
<span style="float: left; margin-right: 5px;">
[
if($_owner.profile_id > 0) {[
	page("icon", $_owner.profile_id);
]} else {
	<b>[$_owner.name]</b>:
};
]
</span>
[_num2link($_body);]
<div style="clear: both;"></div>
<i style="font-size: 80%">Attached to: <a href="/?id=[$_parent]">[get_title($_parent);]</a></i>
[msg_end();]
[end mode overview]

[begin mode abbr]
<li><a href="/?id=[$_id]">[$_title]</a> by [page("link", $_owner.profile_id);]</li>
[$e = children("abbr", $_id);
if($e != "") {<ul>[$e]</ul>};
]
[end mode abbr]

[begin mode delete]
[$n = delete_page($_id);
children("delete", $_id);
if($n == "1") {
	<p><b>[$_title]</b> has been removed from <b>[get_title($_parent)]</b>.</p>
} else {
	<p><b>[$_title]</b> could not be removed from <b>[get_title($_parent)]</b>
	by you ([$_viewer.name]). If you feel that should be able to do so, now
	might be a good time to
	<a href="mailto:[$_globals.ADMIN_EMAIL]"> write a letter to the administrator</a>.</p>
}]
<p><a href="/?id=[$_parent]">Return to [get_title($_parent)]</a></p>
[end mode delete]

[begin mode view]
[msg_start();]
<span style="float: right; font-size: 80%;">
[
    if(can_edit()) { <a href="/?mode=edit&id=[$_id]">edit</a> };
    if(can_direct()) { <a href="/?mode=delete&id=[$_id]">delete</a> };
    if(can_comment()) { <a href="?id=[$_id]&mode=reply">reply</a> };
]
</span>
<span style="float: left; margin-right: 5px;">
[
if($_owner.profile_id > 0) {[
	page("icon", $_owner.profile_id);
]} else {
	<b>[$_owner.name]</b>:
};
]
</span>
[_num2link($_body);]
<div style="clear: both;"></div>
[msg_end();]
<div style="padding-left: 25px">
[children("view", $_id);]
</div>
[end mode view]

[begin mode edit]
<form method="post" action="/">

	<input type="hidden" name="id" value="[$_id]">
	<input type="hidden" name="mode" value="submit">
	<textarea class="textbox" name="body" rows="15">
[edit_display($_body)]</textarea>
	<br><span class="buttonbox"><input type="submit" value="Revise"></span>

</form>
[end mode edit]
[begin mode submit]
	[$_body = $_params.body; msg_start();]
	Post made. <a href="/?id=[$_parent]">Return to parent entry.</a>
	[msg_end();]
[end mode submit]
[begin mode reply]
	[_post_comment($_id, "reply_submit")]
[end mode reply]
[begin mode reply_submit]
    [$title = {Comment on [$_id] at [now()] by [$_viewer.ip]};
	$e = new_page($title, $_id);
	if($e) {[
	    set_body($e, $_params.body);
	    set_template($e, title2id("Generic Comment"));
            set_permissions($e, "cadrec--r-c-dr-c--r-");
            msg_start();]
            Commented successfully!
            <a href="/?id=[$_id]">Return to the comment.</a>
            [msg_end();
        ]} else {[
            msg_start();]
            Couldn't comment.
            Maybe you don't have permissions?
            Are you logged in?
            <a href="/?id=[$_id]">Return to the comment.</a>
            [msg_end();
        ]};
    ]
[end mode reply_submit]